package com.polaris.live.resp.back_resp

import com.polaris.live.common.cacha.CacheUtil
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo

/**
 *BackpackReceivesResp获取用户的背包接收列表
 * @author Created by 天晴 on 2024/7/22 19:27
 * @since 1.0.0
 **/
data class BackpackReceivesResp(
    /**
     * 赠送时间
     */
    val createTime: Long,

    /**
     * 赠送时长，-1为永久
     */
    val duration: Long,

    /**
     * 赠送后的背包过期时间，这个时间减去[duration]是生效时间
     *
     * 如果为空代表永久，当用于判断是否为有效期内时，先判断[inValidPeriod]，然后判断[createTime]，最后判断[expiredTime]
     */
    val expiredTime: Long? = null,

    /**
     * 是否为有效期
     */
    val inValidPeriod: Boolean,

    val userBasic: UserBasicVo,
) {

    fun getType(): Int {
        val serverTime = CacheUtil.getServerTime()
        return if (inValidPeriod) {
            1
        } else {
            if (expiredTime == null) {
                2
            } else {
                if (expiredTime - serverTime > 0) {
                    2
                } else {
                    3
                }
            }
        }

    }

}
